<style lang="scss" scoped>
.inp-app {
  width: 100%;
  height: 28vh;
  // background-color: aqua;
  position: relative;

  &::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(#46bf82, #fff);
    z-index: 3;
  }
}

.inp-app-top {
  z-index: 100;
  width: 100%;
  height: 100%;
  // background-color: antiquewhite;
  position: absolute;
  top: 0;
  left: 0;
  // display: flex;
}

.inp-app-top-search {
  margin-top: 0.3rem;
  width: 85%;
  height: 80%;
  background-color: #fff;
  border-radius: 1.2rem;
  display: flex;

  input {
    flex: 0.7;
    border: none;
    height: 99%;
    font-size: 0.9rem;
  }

  button {
    flex: 0.2;
    border-radius: 1.2rem;
    border: none;
    background-color: #46bf82;
    color: #fff;
    height: 93%;
    // margin: .1rem .1rem;
    margin: 0.5%;
    font-size: 0.9rem;
  }
}

.ul-1 {
  width: 100%;
  height: 50%;

  // background-color: red;
  ul {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    text-align: center;
    font-size: 0.8rem;

    li {
      width: 20%;
      margin-top: 0.5rem;

      img {
        width: 50%;
        height: 60%;
      }
    }
  }
}

.Consultation {
  width: 100%;
  height: 10vh;
  // background-color: red;
  margin-top: 0.5rem;
}

.Consultation-top {
  width: 90%;
  height: 100%;
  background: linear-gradient(#b7e2cc, #fff);
  border-radius: 0.5rem;
  display: flex;
  font-size: 0.8rem;

  p {
    color: #666;
    font-size: 0.7rem;
  }

  button {
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    border: none;
    color: #fff;
    background-color: #39d167;
    margin-top: 30%;
  }
}

.Consultation-top-left {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0.4rem;

  img {
    width: 0.5rem;
  }
}

.SkList {
  width: 100%;
  height: 25vh;
  display: flex;
  padding: 0.4rem;
  background-color: #f2f2f2;

  div {
    padding: 0.1rem;
  }

  img {
    width: 100%;
    height: 100%;
  }
}

.footer {
  position: fixed;
  bottom: 6rem;
  right: 2rem;
  width: 3.5rem;
  height: 3.5rem;
  background-color: #ff7f2f;
  border-radius: 50%;
  text-align: center;
}
</style>
<template>
  <div style="width: 100vw; height: 100vh; background-color: #f2f2f2">
    <div class="inp-app">
      <div class="inp-app-top">
        <div style="display: flex; width: 100%; height: 25%">
          <div class="inp-app-top-search">
            <van-icon
              name="search"
              style="
                flex: 0.1;
                text-align: center;
                color: #46bf82;
                font-weight: 700;
                line-height: 230%;
              "
            />
            <input type="text" placeholder="请输入商品名称" />
            <button>搜索</button>
          </div>
          <van-icon
            name="friends-o"
            style="font-size: 1.5rem; color: #f2f2f2; height: 100%; line-height: 200%"
          />
        </div>
        <div class="ul-1">
          <ul>
            <li v-for="(item, index) in GongList" :key="index">
              <img :src="item.image" alt="" />
              <p>{{ item.name }}</p>
            </li>
          </ul>
        </div>
      </div>
    </div>
    <div class="Consultation">
      <div class="Consultation-top">
        <div>
          <div class="Consultation-top-left">
            <img src="@/assets/img/t13.jpg" alt="" />
            问诊开药
          </div>
          <p>适用于常见病、病情稳定的慢性复诊患者</p>
        </div>
        <div>
          <button>立即问诊</button>
        </div>
      </div>
    </div>
    <!-- 健康护肤 -->
    <div class="SkList">
      <div v-for="(item, index) in SkList" :key="index">
        <img :src="item.img_url" alt="" @click="toSkList(item)" />
      </div>
    </div>
    <Activity></Activity>
    <div class="footer" @click="toCart">
      <van-icon
        name="cart-o"
        style="line-height: 3.5rem; color: #fff; font-size: 1.5rem; font-weight: 600"
      />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import axios from 'axios'
import Activity from '@/compentents/activity/index.vue'
import { useRouter } from 'vue-router'
// 宫格数据
const GongList = ref([])
const SkList = ref([])
const router = useRouter()
// 获取宫格数据
const getGongList = async () => {
  var res = await axios.get('/static/mall/goods/category/info/')
  GongList.value = res.data.data.goods_category
}
getGongList()
// 获取健康护肤数据
const SkincareList = async () => {
  var res = await axios.get('/static/mall/home/recommend_big_card/')
  SkList.value = res.data.data.recommend_big_cards
  // console.log(res.data.data.recommend_big_cards);
}
SkincareList()
// 跳转健康护肤详情
const toSkList = (item) => {
  window.location.href = item.jump_url
}
const toCart = () => {
  router.push('/cart')
}
</script>
